<!doctype html>
<html>
	<head>
		<meta charset="UTF-8" />
		<title>物联系统</title>
		<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta name="robots" content="noindex,nofollow">
		<link href="__TMPL__Public/assets/css/admin_login.css" rel="stylesheet" />
		<style>
			#login_btn_wraper{
				text-align: center;
			}
			#login_btn_wraper .tips_success{
				color:#fff;
			}
			#login_btn_wraper .tips_error{
				color:#DFC05D;
			}
			#login_btn_wraper button:focus{outline:none;}
            .send_sms_btn{
                display: inline-block;
                width: 105px;
                float: right;
                text-decoration: none;
                height: 30px;
                line-height: 30px;
                text-align: center;
                background: #549fcc;
                color: white;
            }
		</style>
		<script>
			if (window.parent !== window.self) {
					document.write = '';
					window.parent.location.href = window.self.location.href;
					setTimeout(function () {
							document.body.innerHTML = '';
					}, 0);
			}
		</script>
		
	</head>
<body>
	<div class="wrap">
		<h1><a>物联系统</a></h1>
		<form method="post" name="login" action="{:U('public/dologin')}" autoComplete="off" >
			<div class="login">
				<ul>
					<li>
						<input class="input"  name="username" id="username"  type="text" placeholder="{:L('USERNAME_OR_EMAIL')}" title="{:L('USERNAME_OR_EMAIL')}" value="{:cookie('admin_username')}" data-rule-required="true"  data-msg-required=""/>
					</li>
					<li>
						<input class="input"  type="password" id="password" name="password" placeholder="{:L('PASSWORD')}" title="{:L('PASSWORD')}" data-rule-required="true"  data-msg-required=""/>
					</li>
					<if condition="$admin != 1">
                        <li>
                            <input class="input" style="width: 120px;" id="sms_code" type="text" name="sms_code" placeholder="验证码" title="短信验证码" data-rule-required="true"  data-msg-required=""/>
                            <a href="javascript:send_smscode()" class="send_sms_btn" >发送验证码</a>
                        </li>
					</if>
					<li class="verifycode-wrapper">
						{:sp_verifycode_img('length=4&font_size=20&width=248&height=42&use_noise=1&use_curve=0','style="cursor: pointer;" title="点击获取"')}
					</li>
					<li>
						<input class="input" type="text" id="verify" name="verify" placeholder="{:L('ENTER_VERIFY_CODE')}" />
					</li>
				</ul>
				<div id="login_btn_wraper">
					<button type="submit" name="submit" class="btn js-ajax-submit" data-loadingmsg="{:L('LOADING')}">{:L('LOGIN')}</button>
				</div>
			</div>
		</form>
	</div>

<script>
var GV = {
    ROOT: "__ROOT__/",
    WEB_ROOT: "__WEB_ROOT__/",
    JS_ROOT: "public/js/"
};
</script>
<script src="__PUBLIC__/js/wind.js"></script>
<script src="__PUBLIC__/js/jquery.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script>
;(function(){
	//document.getElementById('js-admin-name').focus();
})();
</script>
	<if condition="$admin != 1">
	<script>
	var is_send = true;
    function send_smscode(){
		if(is_send){
			var username = $("#username").val();
			var password = $("#password").val();
			if(username == ''){
				alert("请输入用户名");return false;
			}
			if(password == ''){
				alert("请输入密码");return false;
			}
			$.ajax({url:"{:U('Public/send_sms')}",async:false,dataType:"json",data:"username="+username+"&password="+password,type:"post",success:function(t){
				if(t.code == 1){
					alert("发送成功");
					$(".send_sms_btn").html("60秒后重发");
					auto_sms();
				}else{
					alert(t.message);
				}
			}});
		}

    }
	function auto_sms(){
		var time = 60;
		is_send = false;
		_interval  = setInterval(function(){
			time = time-1;
			if(time == 0){
				clearInterval(_interval);
                is_send  = true;
                $(".send_sms_btn").html("发送验证码");
			}
			$(".send_sms_btn").html(time+"秒后重发");
		},1000);
	}
</script>
		</if>
</body>
</html>
